<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>08 js运算符操作</title>
</head>

<body>


    <script>
        var a = 5 + 10;
        var b = 10 - 5;
        var c = a * b;
        var d = 1000 / 4;
        console.log('a:', a);
        console.log('b:', b);
        console.log('c:', c);
        console.log('d:', d);
        // console.log(a, b, c, d);

        var e = 5 % 2;
        console.log('e:', e);

        console.group('不等');
        console.log(3 > 2); //true
        console.log(2 != 3); //true
        console.log(3 != 3); //true
        console.groupEnd();

        console.group('全等、不等');
        console.log('5' === 5); //false
        console.log('5' == 5); //true
        console.log('5' !== 5); //true
        console.groupEnd();

        var a = '3';
        var b = '5';
        var c = a + b;
        console.log('c:', c);
        console.log(a += b);
        console.log('a:', a);

        console.group('非!');
        var a = true;
        console.log(a);
        console.log(!a);
        console.log(!!a);

        var b = false;
        console.log(b);
        console.log(!b);
        console.log(!!b);
        console.groupEnd();

        console.group('++');
        var a1 = 1;
        var a2 = a++; //先赋值，再加一
        console.log('a2:', a2);
        console.log('a1:', a1);

        var a3 = 1;
        var a4 = ++a3;
        console.log('a3:', a3);
        console.log('a4:', a4);
        console.groupEnd();

        //三目运算
        console.group('三目运算')
        var a = 10;
        var c = a > 18 ? '条件成立时' : '条件不成立时';
        console.log('c:', c);
        console.groupEnd();

        var homeSquare = 100;
        var smallCar = 20;

        if (homeSquare > 120 && smallCar > 20) {
            console.log('you and ta getMarry');
        } else {
            console.log('你是一个好人，你会遇到更好的person');
        }

        //i++,++i
        console.group('i++,++i')
        var i = 3; // i = 3
        var a = i++; // a = i(3) ++(+1) a = 3  i = 4
        var b = ++i; // b = ++(+1) i  b = 5 i = 5
        console.log('a:', a); //3
        console.log('b:', b); //5
        console.log('i:', i); //5
        console.groupEnd();
    </script>
</body>

</html>